package com.dev.tools.listener;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Classname MyListener
 * @Description TODO
 * @Date 2022/7/12 17:43
 * @Author niu hao
 */
@Slf4j
@Component
@Async
public class MyListener {

    @SneakyThrows
    @EventListener(MyEvent.class)
    @Order(1)
    public void myListener1(MyEvent event) {
        System.out.println("myListener1");
        String str = event.getStr();
        System.out.println(str);
    }

    @SneakyThrows
    @EventListener(MyEvent.class)
    @Order(2)
    public void myListener2(MyEvent event) {
        System.out.println("myListener2");
        String str = event.getStr();
        System.out.println(str);
    }
}
